import store from '../store/index.js';
//获取位置

//2.获取地址
export function getAddress(location) {
  return new Promise((resolve, reject) => {
    uni.request({
      url: `api?location=${location}&key=WV7BZ-JEJWL-DIYPA-MDJZL-TAW43-2LFNO&get_poi=1`,
      success: (res) => {
        // console.log(res, '+++++++++++++');
        let address = res.data.result;
        // console.log(address);
        resolve(address);
      },
      fail: (err) => {
        reject(err);
      }
    });
  });
}
//翻译地址
export function Translation(from,text,to) {
let tgt_text = 'ئىرىشىش مەغلۇپ بولدى';
	return new Promise((resolve, reject) => {
	        uni.request({
	            url: 'https://api.niutrans.com/NiuTransServer/translation',
	            method: 'POST',
	            data: {
	                from: from,
	                src_text: text,
	                to: to,
	                apikey: 'a743e753d4825fd89b7c1e96b8da9f3a',
	            }
	        }).then(res => {
	            const tgt_text = res.data.tgt_text;
	            // console.log(tgt_text, '++++++++++++++');
	            resolve(tgt_text);
	        }).catch(err => {
	            console.error(err);
	            reject(err);
	        });
	    });
}

